<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<div class="row">
	<div class="col-md-12 col-lg-12 class-title" style="background-image: url(<c:url value='/image/course-info-bg.png'/>);background-size:100% 100%;repeat:no-repeat;">
		<div class="link-intro">
			<a id="navCourseName" ></a>&nbsp;>&nbsp;
			<span class="navClassName" ></span>
		</div>
		<div class="class-course-name navClassName"></div>
		<div class="class-title-info">
			<ul id="theory-time-list">
				<li class="ctitle">理论课</li>
			</ul>
			<ul id="lab-time-list">
				<li class="ctitle">实验课</li>
			</ul>
		</div>
	</div>
</div>

<script>
var initPage=function(){
	var view=data.data.classView;
	var list=data.data.list;
	var dateStr = data.data.classView;
	$("#navCourseName").text(view.courseName);
	$('#navCourseName').attr('href',"<c:url value='/class/courseView/"+view.courseId+"'/>");
	$(".navClassName").text(view.className);
	$("input[name='classCode']").val(view.classCode);
	
	var theory = $("#theory-time-list");
	var lab = $("#lab-time-list");
	var str = "";
	if(view.hasTheory == 0) {
		str = ("<li class=\"lesson-time\">无理论课</li>");
	} else if(view.hasTheory == 1) {
		for(var i=0;i<dateStr.theoryDate.timeOfWeek;i++) {
			str += ("<li class=\"lesson-time\">");
			str += (getWeek(dateStr.theoryDate.date[i].begin.split(" ")[0]));
			str += (" ");
			str += (dateStr.theoryDate.date[i].begin.split(" ")[1]);
			str += ("--");
			str += (dateStr.theoryDate.date[i].end.split(" ")[1]);
			str += ("</li>");
		}
	}
	theory.append(str);
	var str1 = "";
	if(view.hasLab == 0) {
		str1 = ("<li class=\"lesson-time\">无实验课</li>");
	} else if(view.hasLab == 1) {
		for(var i=0;i<dateStr.labDate.timeOfWeek;i++) {
			str1 += ("<li class=\"lesson-time\">");
			str1 += (getWeek(dateStr.labDate.date[i].begin.split(" ")[0]));
			str1 += (" ");
			str1 += (dateStr.labDate.date[i].begin.split(" ")[1]);
			str1 += ("--");
			str1 += (dateStr.labDate.date[i].end.split(" ")[1]);
			str1 += ("</li>");
		}
	}
	lab.append(str1);
	initClass();
}
var getWeek = function(dateString){
    var date;
    if(isNull(dateString)){
        date = new Date();
    }else{
        var dateArray = dateString.split("-");
        date = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
    }
    return "周" + "日一二三四五六".charAt(date.getDay());
}
function isNull(object){ 
    if(object == null || typeof object == "undefined"){ 
        return true; 
    } 
    return false; 
}
</script>